#pragma once
#include <ESP8266WebServer.h>

namespace ganix
{
    namespace http_server
    {
        ESP8266WebServer *server;

        void _on_not_found() {
            Serial.printf("404: %s\n", server->uri().c_str());
            server->send(404, "text/plain", "404: Not Found");
        }

        ESP8266WebServer *get_server() {
            return server;
        }

        void init(int port = 80) {
            server = new ESP8266WebServer(80);
            server->begin();
            server->onNotFound(_on_not_found);
        }
        void loop() {
            server->handleClient();
        }
    } // namespace http_server
    
} // namespace ganix
